<!-- 制冷面积录入 -->
<template>
  <div class="container">
  <div class="header">
    <el-form inline class="searchItem">
      <div style="display: flex;">
        <el-form-item label="项目">
              <el-select
                  v-model="code"
                  filterable
                  placeholder="请选择项目"
                  transfer
                  style="width: 100%"
              >
                  <el-option
                      v-for="item in projectList"
                      :key="item.code"
                      :value="item.code"
                      :label="item.name"
                  />
              </el-select>
        </el-form-item>
        <el-form-item label="补录年份">
            <el-date-picker
                v-model="year"
                type="year"
                :editable="false"
                :clearable="false"
                style="width: 100%;"
                class="calendar-single"
                :pickerOptions="pickerOptions"
            />
        </el-form-item>
        <el-form-item label="更新人">
            <el-input
                v-model="name"
                size="small"
                placeholder="请输入更新人"
                style="width: 100%;"
            />
        </el-form-item>
      </div>
      <div style="display: flex;">
        <el-form-item>
            <el-button
                size="small"
                type="primary"
                @click="handleSearch" 
                icon="el-icon-search"
                >查询</el-button
            >
            <el-button
                size="small"
                type="warning"
                @click="handleReset"
                icon="el-icon-refresh-left"
                >重置</el-button
            >
            <el-button
                size="small"
                type="primary"
                @click="addOnClick" 
                icon="el-icon-plus"
                >新增</el-button
            >
        </el-form-item>
      </div>
      </el-form>
  </div>
  <div class="main">
  </div>
</div>
</template>

<script>
import dayjs from 'dayjs';
import { finPageList } from '@/api/measuringType'
import Operation from './components/Operation.vue'
import FormModal from './components/FormModal.vue'
import { findProArchiveOptions } from '@/api/proArchive'
export default {
    components: {
        Operation,
        FormModal
    },
    data() {
        return {
            name: '',
            code: '',
            year: dayjs().format('YYYY'),
            projectList: [
                {
                    name: '123',
                    code: '123',
                    energyTypeName: '123',
                }
            ],
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() > new Date().getTime()    //使用这种方法实现
                },
            },
        }
    },
    created() {
        findProArchiveOptions().then((res) => {
            if (res.code == '200') {
                const resData = res.data || []
                this.projectList = resData
            }
        })
    },
    methods: {
        handleSearch(){
        this.$nextTick(() => {
            const rlTable = this.$refs.rlTable
            if(rlTable){
                rlTable.onSearchChange()
            }
            })
        },
        loadTableData({ resolve, params }) {
            resolve({
                records:this.list,
                total:0
            })
            // finPageList(params).then((res) => {
            //     if (res.code == '200') {
            //         const resData = res.data || {}
            //         resolve({
            //             records: resData.records || [],
            //             total: resData.total,
            //         })
            //     } else {
            //         resolve({
            //             records: [],
            //             total: 0,
            //         })
            //     }
            // })
        },
        handleReset() {
            this.name = ''
            this.handleSearch()
        },
        addOnClick() {
            new this.$pageModal(
                FormModal,
                {
                    props: {
                        title: '新增',
                    },
                },
                (result) => {
                    if (result) {
                      const rlTable = this.$refs.rlTable
                      if(rlTable){
                        rlTable.onSearchChange()
                      }
                    }
                }
            )
        },
    },
}
</script>

<style lang="scss" scoped>
.container {
  color: #fff;
  display: flex;
  flex-direction: column;
  width: 100%;
}
.header {
  height: 36px;
  background-color: #0C2E64;
  padding: 20px 15px;
  display: flex;
  .searchItem {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  margin-bottom: 34px;
}
.main {
  height: calc(100vh - 285px);
  position: relative;
  box-sizing: border-box;
}
::v-deep .el-form-item {
  margin-bottom: 0 !important;
  line-height: 36px !important;
  height: 36px !important;
}
::v-deep .el-form-item__label {
  line-height: 36px !important;
  height: 36px!important;
}
::v-deep .el-form-item__content {
  line-height: 36px !important;
  height: 36px !important;
}
::v-deep .el-input__inner {
  line-height: 32px !important;
  height: 32px !important;
}
.calendar-single ::v-deep.el-icon-date:before {
    content: '' !important;
}
.calendar-single ::v-deep.el-input__suffix {
    width: 25px !important;
}
.calendar-single ::v-deep i:last-child {
    background: url('~@/assets/image/operation/calendar.svg') center center no-repeat !important;
    background-size: 18px 18px !important;
}
.calendar-single ::v-deep.el-range-separator {
    line-height: 28px !important;
}
</style>